#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Project: spd-sxmcc
"""
@author: lyndon
@time Created on 2018/11/19 12:03
@desc
功能：调用百度地图接口爬取各城市小区基本信息
调用接口：Place APIWeb服务API      url：http://lbsyun.baidu.com/index.php?title=webapi/guide/webservice-placeapi
        Geocoding APIWeb服务API   url：http://lbsyun.baidu.com/index.php?title=webapi/guide/webservice-geocoding
数据库：house.community_info
字段：'name', 'address', 'city', 'district', 'scope', 'crawler_time', 'location'

"""

try:
    from crawler_module import community_info
except:
    import community_info
import time

if __name__ == '__main__':
    a = [('杭州', [30.4582460000, 119.8922790000, 30.1479400000, 120.6408190000]),
         ('北京', [40.3151980000, 115.7020240000, 39.5770810000, 117.0335290000]),
         ('上海', [31.4260020000, 121.1090570000, 30.8731770000, 121.9392350000]),
         ('广州', [23.1852140000, 113.1890830000, 22.6491570000, 113.5918110000]),
         ('深圳', [22.7734420000, 113.7838330000, 22.3906220000, 114.3794460000]),
         ('南京', [32.4371590000, 118.3747230000, 31.8992230000, 119.2049010000]),
         ('济南', [36.7355790000, 116.8419980000, 36.5799340000, 117.3203280000]),
         ('重庆', [29.6732250000, 106.3021180000, 29.4102850000, 106.7804480000]),
         ('青岛', [36.6390240000, 119.9957000000, 35.9071840000, 120.8017310000]),
         ('大连', [39.0805160000, 121.0735680000, 38.8619430000, 121.7157490000]),
         ('宁波', [30.0171180000, 121.4077110000, 29.6853290000, 121.8170510000]),
         ('厦门', [24.6268840000, 117.9478020000, 24.4154270000, 118.2450340000]),
         ('成都', [30.8966130000, 103.7507720000, 30.5240300000, 104.2647470000]),
         ('武汉', [30.7207000000, 114.1312360000, 30.4212040000, 114.5239030000]),
         ('哈尔滨', [45.8530720000, 126.4512390000, 45.5355840000, 127.0278790000]),
         ('沈阳', [42.0065330000, 123.1972930000, 41.6146800000, 123.7486370000]),
         ('西安', [34.4725210000, 108.1609000000, 34.0342580000, 109.4774560000]),
         ('长春', [44.0637620000, 125.0409160000, 43.7128250000, 125.6054830000]),
         ('长沙', [28.3946260000, 112.6841060000, 28.0371120000, 113.2113030000]),
         ('福州', [26.1688100000, 119.1421770000, 25.9304270000, 119.5426060000]),
         ('南昌', [28.7944680000, 115.7332320000, 28.5063950000, 116.0528850000]),
         ('合肥', [31.9998630000, 117.0551390000, 31.6921480000, 117.5087470000]),
         ('郑州', [34.9179840000, 113.4948780000, 34.6062510000, 113.9657340000]),
         ('石家庄', [38.1679890000, 114.2795970000, 37.9552500000, 114.6958360000]),
         ('苏州', [31.4552580000, 120.4292830000, 31.1046660000, 120.9030140000]),
         ('佛山', [23.1270500000, 112.9962730000, 22.9274910000, 113.2636090000]),
         ('东莞', [23.1087920000, 113.6438950000, 22.9219870000, 114.1797160000]),
         ('无锡', [31.8931660000, 120.0925090000, 31.3480540000, 120.9939770000]),
         ('烟台', [37.8594990000, 120.2461680000, 37.3334120000, 121.8605310000]),
         ('太原', [38.0184780000, 112.4213080000, 37.7039610000, 112.6725460000])]

    into_db=("0","0","0","utf8")

    for x, y in a:
       example1 = community_info.community_info(y, x, into_db)
       print '现在进行的城市是' + x
       example1.do()